package com.sqx.modules.fixedClassify.controller;

import com.sqx.common.utils.Result;
import com.sqx.modules.fixedClassify.entity.FixedClassify;
import com.sqx.modules.fixedClassify.service.FixedClassifyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@Api(value = "一口价分类", tags = {"管理端:一口价分类"})
@RequestMapping(value = "/admin/fixedClassify/")
public class AdminFixedClassifyController {
    @Autowired
    private FixedClassifyService classifyService;

    @ApiOperation("新增分类")
    @PostMapping("addClassify")
    public Result addClassify(FixedClassify fixedClassify) {
        return classifyService.addClassify(fixedClassify);
    }

    @ApiOperation("修改分类")
    @PostMapping("updateClassify")
    public Result updateClassify(FixedClassify fixedClassify) {
        return classifyService.updateClassify(fixedClassify);
    }

    @ApiOperation("删除分类")
    @GetMapping("deleteById")
    public Result deleteById(Long classifyId) {
        return classifyService.deleteClassify(classifyId);
    }

    @ApiOperation("获取Tree分类列表")
    @GetMapping("getTreeClassifyList")
    public Result getTreeClassifyList(FixedClassify fixedClassify) {
        return Result.success().put("data", classifyService.getTreeClassifyList(fixedClassify));
    }
    @ApiOperation("获取分类列表(非Tree)")
    @GetMapping("getClassifyList")
    public Result getClassifyList(FixedClassify fixedClassify) {

        return Result.success().put("data", classifyService.getClassifyList(fixedClassify));
    }

    @ApiOperation("获取分类信息")
    @GetMapping("getClassifyById/{classifyId}")
    public Result getClassifyInfo(@PathVariable("classifyId") Long classifyId){
        return Result.success().put("data", classifyService.getById(classifyId));
    }
}
